webix.ready(function(){

  var params=new Array();
  var URL="";
  var my_template={
      template: "<span style='font-size:20px; font-weight:bold; color:#3498DB'; >库存详情</span>&nbsp;/&nbsp;&nbsp;InventoryDetail <input type='button' value=' 导 出 ' onclick='exportExcel()' style='background: #268fd5;background: 1px solid #268fd5;color: #fff;'>",
      height:45,
      borderless:true 
  };
 
  var my_datatable={
      view:"datatable",
      id:"mydatatable",     
      columns:[
        // {id:"like", header:{ content:"masterCheckbox" }, template:"{common.checkbox()}", width:40},
        {id:"material_id",header:["内部物料id"],width:190,hidden:true},
        {id:"cutter_specs",header:["规格"],width:190,hidden:true},
        {id:"customer_specs_no",header:["物料编码"],width:190},
        {id:"simple_specs_cust",header:["规格简称"],width:190},
        {id:"long_specs_cust",header:["规格全称"],width:190},
        {id:"supp_name",header:["供应商",{content:"textFilter"}],width:140},
        {id:"real_name",header:["操作人",{content:"textFilter"}],width:100},
        {id:"num",header:"操作数量",width:350},
        {id:"type",header:["操作类型",{content:"textFilter"}],width:100},
        {id:"time",header:"操作时间",width:350,fillspace:true},
        //{id:"cysl",header:"持有数量",/*width:100*/fillspace:true},  
      ],  
      autoheight:true,      
      select:true,
      tooltip:true,
      editable:true,
      checkboxRefresh:true,
      // url:URL
  };
  var page={
    view:"pager",
    id:"pagerA",
    template:"{common.first()}{common.prev()}{common.pages()}{common.next()}{common.last()}",
    css:"pager",
    on: {
      onItemClick: function(id, e, node){
        if (id == "next") {
          if($$("pagerA").config.limit==$$("pagerA").config.page+1)
            {
              id = $$("pagerA").config.limit-1;
            }
          else
          {
            id=$$("pagerA").config.page+1;
          }
        }
        else if(id=="prev")
        {
          id=$$("pagerA").config.page-1; 
        }
        else if(id=="first")
        {
          id=0;
        }
        else if(id=="last")
        {
          id=$$("pagerA").config.limit-1;
        } 
         var params={};
         params.material_id = $("#material_id").val();
         params.date = $("#date").val();
        params.currPage =parseInt(id)+1;
        params.pageSize =20;
        postData("cutterUseDetail", params,callback);
      }
    },
    height:38,
    css:{"text-align": "center","margin-top":"20px!important"}
  };
  var params={};
  params.material_id = $("#material_id").val();
  //params.date = $("#date").val();
  params.pageSize =20;
  postData("cutterUseDetail", params,callback);
  var web={
      container:"body",
      type:"line",
      id:"mylayout",
      rows:[
        my_template,
        {height:20},
        my_datatable,
        page
      ],
  };
  webix.ui(web);//---webix.ui结束----   
  function callback(data){
    text1=JSON.parse(data); 
    var data = new webix.DataCollection({data:text1.data.page});
    $$('mydatatable').data.sync(data.data);
    $$("pagerA").define("limit",text1.data.totalPageCount);
    $$("pagerA").define("count",text1.data.totalCount);
    $$("pagerA").define("size",text1.data.pageSize);
    $$("pagerA").define("page",text1.data.currPage-1);
    $$('pagerA').refresh();
  }
/*-------all end----------*/
});             


